package windows;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JRadioButton;

import controllers.Config;
import controllers.DataInsertion;
import controllers.Map;
import controllers.Point;

import ships.Destroyer;
import ships.Frigate;
import ships.Hunter;
import ships.Submarine;
import ships.Transport;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ButtonGroup;

import com.sun.org.apache.xml.internal.utils.SuballocatedByteVector;



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Jens
 */
public class GameLobby extends javax.swing.JFrame {
	public static String attackWeapon;
	public static String defenceWeapon;
	public static String groupName;

    JRadioButton rdbtnAlliedDestroyer = new JRadioButton("Allied Destroyer");
    
    JRadioButton rdbtnAlliedFrigate = new JRadioButton("Allied Frigate");
    
    JRadioButton rdbtnAlliedHunter = new JRadioButton("Allied Hunter");
    
    JRadioButton rdbtnAlliedSubmarine = new JRadioButton("Allied Submarine");
    
    JRadioButton rdbtnAxisDestroyer = new JRadioButton("Axis Destroyer");
    
    JRadioButton rdbtnAxisFrigate = new JRadioButton("Axis Frigate");
    
    JRadioButton rdbtnAxisHunter = new JRadioButton("Axis Hunter");
    
    JRadioButton rdbtnAxisSubmarine = new JRadioButton("Axis Submarine");
    /**
     * Creates new form GameLobby
     */

	public WindowManager windowManager;
	
	public GameLobby() {
        initComponents();
    }

	public GameLobby(WindowManager windowManager) {
		this.windowManager = windowManager;
        initComponents();
    }
	
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    
	public void transporter(){
		
		
		
	
	}
    
    
    private void initComponents() {
        jButton1 = new javax.swing.JButton();
        jButton1.addActionListener(new ActionListener() {
        	public void actionPerformed(ActionEvent arg0) {
        		        		
        		if (rdbtnAlliedDestroyer.isSelected())
        		{
        			Config.getConfig().ownBoat = "Allied Destroyer";
        			Destroyer AlliedDestroyer = new Destroyer(new Point (20,20));
        			Map.getMap().dObjects.set(0, AlliedDestroyer);
        			AlliedDestroyer.setImage("\\allied\\land.png");
        			AlliedDestroyer.setShipName("Allied Destroyer");
        			groupName = "allied";
        			Config.getConfig().setWeaponsOnShip("Destroyer");
        			
        		}
        		
        		if (rdbtnAlliedFrigate.isSelected())
        		{
        			Config.getConfig().ownBoat = "Allied Frigate";
        			Frigate AlliedFrigate = new Frigate(new Point(20,20));
        			Map.getMap().dObjects.set(0, AlliedFrigate);
        			AlliedFrigate.setImage("\\allied\\land.png");
        			AlliedFrigate.setShipName("Allied Frigate");
        			System.out.print(AlliedFrigate);
        			groupName = "allied";
        			Config.getConfig().setWeaponsOnShip("Frigate");
        		}
        		
        		if (rdbtnAlliedHunter.isSelected())
        		{
        			Config.getConfig().ownBoat = "Allied Hunter";
        			Hunter AlliedHunter = new Hunter(new Point (20,20));
        			Map.getMap().dObjects.set(0, AlliedHunter);
        			AlliedHunter.setImage("\\allied\\land.png");
        			AlliedHunter.setShipName("Allied Hunter");
        			groupName = "allied";
        			Config.getConfig().setWeaponsOnShip("Hunter");
        		}
        		
        		if (rdbtnAlliedSubmarine.isSelected())
        		{
        			Config.getConfig().ownBoat = "Allied Submarine";
        			Submarine AlliedSubmarine = new Submarine(new Point (20,20));
        			Map.getMap().dObjects.set(0, AlliedSubmarine);
        			AlliedSubmarine.setImage("\\allied\\sub.png");
        			AlliedSubmarine.setShipName("Allied Submarine");
        			groupName = "allied";
        			Config.getConfig().setWeaponsOnShip("Submarine");
        		}
        		
        		if (rdbtnAxisDestroyer.isSelected())
        		{
        			Config.getConfig().ownBoat = "Axis Destroyer";
        			Destroyer AxisDestroyer = new Destroyer(new Point (20,20));
        			Map.getMap().dObjects.set(0, AxisDestroyer);
        			AxisDestroyer.setImage("\\axis\\land.png");
        			AxisDestroyer.setShipName("Axis Destroyer");
        			groupName = "Axis";
        			Config.getConfig().setWeaponsOnShip("Destroyer");
        		}
        		
        		if (rdbtnAxisFrigate.isSelected())
        		{
        			Config.getConfig().ownBoat = "Axis Frigate";
        			Frigate AxisFrigate = new Frigate(new Point(20,20));
        			Map.getMap().dObjects.set(0, AxisFrigate);
        			AxisFrigate.setImage("\\axis\\land.png");
        			AxisFrigate.setShipName("Axis Frigate");
        			groupName = "Axis";
        			Config.getConfig().setWeaponsOnShip("Frigate");
        		}
        		
        		if (rdbtnAxisHunter.isSelected())
        		{
        			Config.getConfig().ownBoat = "Axis Hunter";
        			Hunter AxisHunter = new Hunter(new Point (20,20));
        			Map.getMap().dObjects.set(0, AxisHunter);
        			AxisHunter.setImage("\\axis\\land.png");
        			AxisHunter.setShipName("Axis Hunter");
        			groupName = "Axis";
        			Config.getConfig().setWeaponsOnShip("Hunter");
        		}
        		
        		if (rdbtnAxisSubmarine.isSelected())
        		{
        			Config.getConfig().ownBoat = "Axis Submarine";
        			Submarine AxisSubmarine = new Submarine(new Point (20,20));
        			Map.getMap().dObjects.set(0, AxisSubmarine);
        			AxisSubmarine.setImage("\\axis\\sub.png");
        			AxisSubmarine.setShipName("Axis Submarine");
        			groupName = "Axis";
        			Config.getConfig().setWeaponsOnShip("Submarine");
        		}
        		
        		
        	}
        });
        jButton1.addMouseListener(new MouseAdapter() {
        	@Override
        	public void mouseClicked(MouseEvent e) {
        		windowManager.showWindow(windowManager.gameConsole);
        	}
        });

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("CMS - Lobby");

        jButton1.setText("Enter Game");
        


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        layout.setHorizontalGroup(
        	layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(layout.createSequentialGroup()
        			.addGap(33)
        			.addGroup(layout.createParallelGroup(Alignment.LEADING)
        				.addComponent(jButton1)
        				.addComponent(rdbtnAxisSubmarine)
        				.addComponent(rdbtnAxisHunter)
        				.addComponent(rdbtnAxisFrigate)
        				.addComponent(rdbtnAxisDestroyer)
        				.addComponent(rdbtnAlliedSubmarine)
        				.addComponent(rdbtnAlliedHunter)
        				.addComponent(rdbtnAlliedFrigate)
        				.addComponent(rdbtnAlliedDestroyer))
        			.addGap(175))
        );
        buttonGroup.add(rdbtnAlliedDestroyer);
        buttonGroup.add(rdbtnAlliedFrigate);
        buttonGroup.add(rdbtnAxisSubmarine);
        buttonGroup.add(rdbtnAxisHunter);
        buttonGroup.add(rdbtnAxisFrigate);
        buttonGroup.add(rdbtnAxisDestroyer);
        buttonGroup.add(rdbtnAlliedSubmarine);
        buttonGroup.add(rdbtnAlliedHunter);
        layout.setVerticalGroup(
        	layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(layout.createSequentialGroup()
        			.addGap(39)
        			.addComponent(rdbtnAlliedDestroyer)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(rdbtnAlliedFrigate)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(rdbtnAlliedHunter)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(rdbtnAlliedSubmarine)
        			.addGap(18)
        			.addComponent(rdbtnAxisDestroyer)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(rdbtnAxisFrigate)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(rdbtnAxisHunter)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(rdbtnAxisSubmarine)
        			.addGap(18)
        			.addComponent(jButton1)
        			.addContainerGap(95, Short.MAX_VALUE))
        );
        getContentPane().setLayout(layout);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GameLobby.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GameLobby.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GameLobby.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GameLobby.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GameLobby().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private final ButtonGroup buttonGroup = new ButtonGroup();
}
